package com.sise.aio和bio和nio.bio.bio3;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author idea
 * @data 2019/4/6
 */
public class Client {

    private static PrintWriter pw = null;
    private static BufferedReader br = null;
    private static Socket s;

    private static Scanner scanner = new Scanner(System.in);


    public static void main(String[] args) throws IOException {
        Socket s = new Socket(InetAddress.getLocalHost(), 9099);
        br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        pw = new PrintWriter(new OutputStreamWriter(s.getOutputStream()));
        while (true) {
            System.out.println("Client端请输入：");
            String content = scanner.next();
            if (content.equals("exit")) {
                System.out.println("输入结束");
                break;
            } else {
                //这里要用println的话，那么server端则必须要用readline换行读取的方式才能接受到数据
                pw.println(content);
                pw.flush();
            }
        }
        pw.close();
        br.close();
    }
}
